#include <iostream>
#include <thread>

// 定义一个线程局部变量
thread_local int n = 0;

void increment_and_print() {
    ++n; // 每个线程都会修改自己的n副本
    std::cout << "Thread " << std::this_thread::get_id() << " n = " << n << std::endl;
}

int main() {
    std::thread t1(increment_and_print);
    std::thread t2(increment_and_print);
    t1.join();
    t2.join();
    return 0;
}